package admincow.servlet.inseminacion;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import admincow.dao.InseminacionDAO;
import admincow.vo.InseminacionVO;

/**
 * Servlet implementation class for Servlet: InseminacionBuscarServlet
 *
 */
 public class InseminacionBuscarServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
   static final long serialVersionUID = 1L;
   
    /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public InseminacionBuscarServlet() {
		super();
	}   	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}  	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("InseminacionBuscarServlet");
		String x = request.getParameter("nombre");
		System.out.println(x);
		InseminacionDAO dao = new InseminacionDAO();
		Collection<InseminacionVO> linse = dao.buscarPorNombre(x);

		// Guardar arreglo en ambiente request
		request.setAttribute("arreglo", linse);

		// Hacer forward a jsp (cooperacion)
		RequestDispatcher rd = request
				.getRequestDispatcher("/inseminacionBuscar.jsp");
		rd.forward(request, response);

	}   	  	    
}